﻿using UnityEngine;
using System.Collections;

public class WebCamCap : MonoBehaviour {

	private WebCamTexture webcamTex;
	public GameObject DispObj;

	int camW=640;
	public int CamW {
		get {
			return camW;
		}
	}

	int camH=480;
	public int CamH {
		get {
			return camH;
		}
	}

	Color32[] clrs;





	public WebCamTexture WebCameraTex
	{
		get
		{
			return webcamTex;
		}
	}


	//Texture2D txdemo;


	// Use this for initialization
	void Start () {
		WebCamDevice[] device = WebCamTexture.devices;
		
		webcamTex = new WebCamTexture(camW,camH);

		//txdemo=new Texture2D(CamW, CamH);
		clrs=new Color32[camW*camH];
		//DispObj.GetComponent<Renderer>().material.mainTexture = webcamTex;
	
		if(device.Length>0){
			webcamTex.deviceName = device[0].name;
			webcamTex.Play();
		}

	
	}
	
	// Update is called once per frame
	void Update () {






	}
}
